package cn.dslcode.security.config;

import cn.dslcode.security.config.security.CustomSecurityConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @author dongsilin
 * @version 2018/4/9.
 */
@Configuration
public class WebMvcConfiguration extends WebMvcConfigurerAdapter {

    @Autowired
    private CustomSecurityConstant securityConstant;

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("index");
        registry.addViewController(securityConstant.getUri().getLoginForm()).setViewName("login");
        registry.addViewController("/user/list/page").setViewName("userList");
        registry.addViewController("/user/edit/page").setViewName("userEdit");
        registry.addViewController("/user/authority/edit/page").setViewName("userAuthorityEdit");
        registry.addViewController(securityConstant.getUri().getUnauthorized()).setViewName("403");
    }

}
